<template>
  <div class="goods-table">
    <el-table :data="tableData" :rules="tableRules">
      <el-table-column type="index" label="#"></el-table-column>
      <el-table-column
        v-for="(item, i) in TableLabelsAndData.labels"
        :key="item"
        :label="item"
        :prop="TableLabelsAndData.datas[i]"
      ></el-table-column>
      <el-table-column label="添加时间">
        <template #default="scope">
          {{ scope.row.add_time | dateFormat }}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template #default="scope">
          <el-button icon="el-icon-edit" type="primary" size="mini"
            >编辑</el-button
          >
          <el-button
            icon="el-icon-delete"
            type="danger"
            size="mini"
            @click="removeGood(scope.row.goods_id)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "goodsTable",
  props: {
    tableData: {
      type: Array,
      default() {
        return [];
      }
    },
    tableRules: {
      type: Object,
      default() {
        return {};
      }
    },
    TableLabelsAndData: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  methods: {
    removeGood(id) {
      this.$emit("removeGood", id);
    }
  }
};
</script>

<style lang="scss" scoped></style>
